import java.util.Scanner;

// day19之汽水瓶问题
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while(in.hasNextInt()) {
            int n = in.nextInt();
            if(n == 0)
                return;
            int result = 0;
            while(n >= 3) {
                int k = n / 3;
                result += k;
                n %= 3;
                n += k;
            }
            if(n == 2)
                result++;
            System.out.println(result);
        }
    }
}